package com.laolei.eureka.client;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.DiscoveryClient;

@SpringBootApplication
public class SpringEurekaClientApplication implements InitializingBean{
	@Autowired DiscoveryClient discoveryClient;

	public static void main(String[] args) {
		SpringApplication.run(SpringEurekaClientApplication.class, args);
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		discoveryClient.getInstances("DEMO-SERVICE").forEach(p->{
			System.err.println(p.getHost()+":"+p.getPort()+" "+p.getServiceId()+" "+p.getUri());
		});
	}
}
